//
//  UIBarButtonItem+YJWExtension.m
//  百思不得骑姐
//
//  Created by YJW on 16/10/12.
//  Copyright © 2016年 yijiang. All rights reserved.
//

#import "UIBarButtonItem+YJWExtension.h"

@implementation UIBarButtonItem (YJWExtension)

+(UIBarButtonItem*)itemWithImg:(NSString*)img highlightedImg:(NSString*)highlightedImg target:(id)target action:(SEL)action{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setBackgroundImage:[UIImage imageNamed:img] forState:UIControlStateNormal];
    [btn setBackgroundImage:[UIImage imageNamed:highlightedImg] forState:UIControlStateHighlighted];
    btn.size = btn.currentBackgroundImage.size;
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    return [[self alloc] initWithCustomView:btn];
}

@end
